package cn.service.orderService.OrderServiceImpl;

import cn.service.orderService.OrderSettingService;
import entity.orderEntity.OrderSetting;
import entity.Result;
import mapper.orderMapper.OrderSettingMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 朱颢阳
 * @description
 * @time 2024/8/24 16:47
 */
@Service
public class OrderSettingServiceImpl implements OrderSettingService {
    @Resource
    OrderSettingMapper mapper;

    @Override
    public Result setorder_setting(OrderSetting orderSetting) {
        if (orderSetting.getOrder_setting_id()==null){
            if(mapper.insert(orderSetting)>0){
                return Result.success("设置成功");
            }else{
                return Result.failed(500,"设置失败！");
            }
        }else{
            if(mapper.updateByPrimaryKeySelective(orderSetting)>0){
                return Result.success("设置成功");
            }else{
                return Result.failed(500,"设置失败！");
            }
        }

    }

    @Override
    public Result getsetting() {
        return Result.success(200,mapper.selectByPrimaryKey());
    }

    @Override
    public Result getautocomplete() {
        return Result.success(200,mapper.getautocomplete());
    }
}
